#导入原有的包
from flask_restful import Api
#导入自己修改的包
from toutiaoapi.output import output_json


class BaseApi(Api):

    #把设计返回响应数据的相关方法找到复制过来重写
    def __init__(self, app=None, prefix='',
                 default_mediatype='application/json', decorators=None,
                 catch_all_404s=False, serve_challenge_on_401=False,
                 url_part_order='bae', errors=None):

        #继承原来父类的不变
        super().__init__(app=app,prefix=prefix,
                         default_mediatype=default_mediatype,decorators=decorators,
                         catch_all_404s=catch_all_404s,serve_challenge_on_401=serve_challenge_on_401,
                         url_part_order=url_part_order,errors=errors)

        #只修改需要改动的部分,导入被修改的output_json
        self.representations = {'application/json':output_json}